package com.aierkeji.call.b2c.controller;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aierkeji.call.b2c.contants.Contants;
import com.aierkeji.call.b2c.entity.AkjCallClueVo;
import com.aierkeji.call.b2c.service.AkjCallClueService;

@RestController
@RequestMapping("callClue")
public class AkjCallClueController extends BaseController{
	
	private final Logger log = LogManager.getLogger(getClass());
	
	@Autowired
	AkjCallClueService akjCallClueService;
	
	/**
	 * 查询线索
	 * @param map
	 * @return
	 */
	@PostMapping("findCallClue")
	//增加了这个注解就可以角色控制
    @RequiresRoles(value= {Contants.ROLE_ID_SALES,Contants.ROLE_ID_MANAGER},logical=Logical.OR)
	public Map<String, Object> findCallClue(@RequestBody  Map<String, Object> map) {
		
		return akjCallClueService.findCallClue(map);
	}
	
	/**
	 * 查询线索详情
	 * @param map
	 * @return
	 */
	@PostMapping("findCallClueDetail")
	//增加了这个注解就可以角色控制
    @RequiresRoles(value= {Contants.ROLE_ID_SALES,Contants.ROLE_ID_MANAGER},logical=Logical.OR)
	public Map<String, Object> findCallClueDetail(@RequestBody  Map<String, Object> map) {
		
		return akjCallClueService.findCallClueDetail(map);
	}
	
	/**
	 * 上传监控线索的信息
	 * @param map
	 * @return
	 */
	@PostMapping("uploadCallClue")
	//增加了这个注解就可以角色控制
    @RequiresRoles(value= { Contants.ROLE_ID_MANAGER,Contants.ROLE_ID_SALES},logical=Logical.OR)
	public Map<String, Object> uploadCallClue(@RequestBody  Map<String, Object> map, HttpServletRequest request){
		return akjCallClueService.uploadCallClue(map,request);
	}
	
}
